<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js中自定义对象</title>
</head>
<body>
<script>
  //创建对象
  var user = {
    name:'zhangsan',
    age:18,
    eat:function (){},
    sleep:function (){}
  }
  //使用对象
  console.log("姓名"+user.name);
  user.eat();

  for (var temp in user) {
    console.log(temp,user[temp]);
  }
</script>
</body>
</html>